{extend name="index/index"/}



{block name="main"}

<script>
    //图片上传预览    IE是用了滤镜。
    function previewImage(file)
    {
        var MAXWIDTH  = 90;
        var MAXHEIGHT = 90;
        var div = document.getElementById('preview');
        if (file.files && file.files[0])
        {
            div.innerHTML ='<img id=imghead onclick=$("#previewImg").click()>';
            var img = document.getElementById('imghead');
            img.onload = function(){
                var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
                img.width  =  rect.width;
                img.height =  rect.height;
//                 img.style.marginLeft = rect.left+'px';
                img.style.marginTop = rect.top+'px';
            }
            var reader = new FileReader();
            reader.onload = function(evt){img.src = evt.target.result;}
            reader.readAsDataURL(file.files[0]);
        }
        else //兼容IE
        {
            var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
            file.select();
            var src = document.selection.createRange().text;
            div.innerHTML = '<img id=imghead>';
            var img = document.getElementById('imghead');
            img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
            var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
            status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
            div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;"+sFilter+src+"\"'></div>";
        }
    }
    function clacImgZoomParam( maxWidth, maxHeight, width, height ){
        var param = {top:0, left:0, width:width, height:height};
        if( width>maxWidth || height>maxHeight ){
            rateWidth = width / maxWidth;
            rateHeight = height / maxHeight;

            if( rateWidth > rateHeight ){
                param.width =  maxWidth;
                param.height = Math.round(height / rateWidth);
            }else{
                param.width = Math.round(width / rateHeight);
                param.height = maxHeight;
            }
        }
        param.left = Math.round((maxWidth - param.width) / 2);
        param.top = Math.round((maxHeight - param.height) / 2);
        return param;
    }
</script>


<div class=" admin-content">
<div class="admin-biaogelist">
	
    <div class="listbiaoti am-cf">
      <ul class="am-icon-flag on"> 修改广告</ul>
      <dl class="am-icon-home" style="float: right;"> 当前位置： 首页 > <a href="#">修改广告</a></dl>
    </div>
    <div class="fbneirong">
      <form class="am-form" enctype ="multipart/form-data" method ="post" action="{:url('admin/advertisingby/update',['id'=>$data['id']])}">
        <div class="am-form-group am-cf">
          <div class="zuo">标题：</div>
          <div class="you">
            <input type="hidden" name="_method" value="PUT">
            <input type="hidden" name="path" value="{$data['upload_path']}">
            <input type="text" class="am-input-sm" id="doc-ipt-email-1" placeholder="请输入标题" name="title" value="{$data['title']}">
          </div>
        </div>

        <div class="am-form-group am-cf">
          <div class="zuo">描述：</div>
          <div class="you">
            <input type="text" name="describe" value="{$data['describe']}">
          </div>
        </div>

        <div class="am-form-group am-cf">
          <div class="zuo">连接地址：</div>
          <div class="you">
            <input type="text" class="am-input-sm" id="doc-ipt-email-1" placeholder="请输入标题" name="carousel_url" value="{$data['carousel_url']}">
          </div>
        </div>

        
        <div class="am-form-group am-cf">
          <div class="zuo">广告图片：</div>
          <div class="you">
            <div id="preview">
              <img id="imghead" border="0" src="/uploads/advertisingby/{:str_replace('\','/',$data['upload_path'])}" width="90" height="90" onclick="$('#previewImg').click();">
            </div>
            <input type="file" onchange="previewImage(this)" style="display: none;" id="previewImg" name="upload_path" value="{$data['upload_path']}">
            <p class="am-form-help">请选择要修改的文件...</p>
          </div>
        </div>




        <div class="am-form-group am-cf">
          <div class="you" style="margin-left: 20%;">
             <button type="submit" class="am-btn am-btn-secondary am-radius">确认修改</button>
          </div>
        </div>
      </form>
    </div>

</div>

</div>
{/block}